package org.apache.struts.admin.action;

import java.util.ArrayList;

import org.apache.struts.admin.model.SystemUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import com.earogya.springsecurity.security.CreateUsersInterface;
import com.earogya.springsecurity.web.controller.AdminController;
import com.opensymphony.xwork2.ActionSupport;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.ModelAttribute;


public class CreateUserAction extends ActionSupport{

	private SystemUser user;
	@Autowired
	private CreateUsersInterface createUsersDao;
	
	protected Authentication getAuthentication() {
		return SecurityContextHolder.getContext().getAuthentication();
		}

	public String execute() throws Exception{
		AdminController controller=new AdminController();
		controller.submitCreatePage(user.getUsername(), user.getName(), user.getPassword(), user.getEmail(), user.getDepartment());
	return SUCCESS;
	}

	public SystemUser getUser() {
		return user;
	}

	public void setUser(SystemUser user) {
		this.user = user;
	}
	
	
}
